<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('审核本级回复T')"/>
</head>

<body style="background-color: #F4F6FA;font-size: 13px;font-family:'huawen' ;font-weight: bold">
<iframe id="showWorkForm" width="100%" scrolling="no" th:src="@{'/gaoxin/system/mTelWF/cmnFile/showWorkFormInfo/'+${sendBackEty.wfId}}" frameborder="0" seamless></iframe>
<div class="main-content" style="margin: 0;padding: 0">

    <form id="form-user-add" th:object="${sendBackEty}" class="form-horizontal" style="background-color: #F4F6FA">
        <input type="hidden" th:field="*{wfId}"/>
        <input type="hidden" th:field="*{pkId}"/>
        <input type="hidden" th:field="*{sdeptId}"/>
        <input type="hidden" id="sortCode" th:field="*{sortCode}"/>
        <input type="hidden" id="setProId" th:value="${workFormEty.setProId}"/>
        <input type="hidden" id="crtRole" th:value="${user.roles.get(0).roleId}"/>
        <input type="hidden" id="areaNo" th:value="${user.areaNo}"/>
        <input type="hidden" name="crtStepId" id="crtStepId" value="810"/>
        <input type="hidden" name="crtStepName" id="crtStepName" value="待审定结果"/>
        <input type="hidden" name="backState" id="backState" th:value="*{backState}"/>

        <div class="col-sm-12 grid-container" style="display: flex;">
            <!--     左       -->
            <div class="col-sm-8 entering-page" style="padding-bottom: 10px">
                <!--   来电内容     -->
                <div class="col-sm-12 tltieBoder">
                    <div class="blueBorder"></div>
                    <h4 style="margin:0 0 0 10px">回复信息</h4>
                </div>
                <div class="col-sm-12" hidden="hidden">
                    <div class="form-group">
                        <label class="col-sm-3 control-label entering-pd spLBlue">建议办结及理由：</label>
                        <div class="col-sm-9">
                            <!--<span class="tworkformprocess-span">[[*{reason}]]</span>-->
                            <input type="text" id="reason" name="reason" class="form-control" th:value="*{reason}"/>
                        </div>
                    </div>
                </div>
                <div class="col-sm-12">
                    <div class="form-group">
                        <label class="col-sm-3 control-label entering-pd">执行处（科）室：</label>
                        <div class="col-sm-3">
                            <span class="tworkformprocess-span">[[*{bdutyDept}]]</span>
                        </div>
                        <label class="col-sm-2 control-label entering-pd">联系电话：</label>
                        <div class="col-sm-3">
                            <span class="tworkformprocess-span">[[*{bdutyTel}]]</span>
                        </div>
                    </div>
                </div>
                <div class="col-sm-12">
                    <div class="form-group">
                        <label class="col-sm-3 control-label entering-pd">回复人：</label>
                        <div class="col-sm-3">
                            <span class="tworkformprocess-span">[[*{buserName}]]</span>
                        </div>
                        <label class="col-sm-2 control-label entering-pd">回复时间：</label>
                        <div class="col-sm-3">
                            <span class="tworkformprocess-span">[[*{#dates.format(backTime,'yyyy-MM-dd HH:mm:ss')}]]</span>
                        </div>

                    </div>
                </div>
                <div class="col-sm-12">
                    <div class="form-group">
                        <label class="col-sm-3 control-label entering-pd">备注：</label>
                        <div class="col-sm-3">
                            <!--<span class="tworkformprocess-span">[[*{backRemark}]]</span>-->
                            <input type="text" id="backRemark" name="backRemark" class="form-control"  th:value="*{backRemark}"/>
                        </div>
                    </div>
                </div>
                <div class="col-sm-12">
                    <div class="form-group">
                        <label class="col-sm-3 control-label entering-pd">回复内容（供派单部门使用）：</label>
                        <div class="col-sm-8">
                            <textarea  id="backDesc" name="backDesc" th:text="*{backDesc}" class="form-control phoneRemark"  style="height: 120px"></textarea>
                        </div>
                    </div>
                </div>
                <div class="col-sm-12">
                    <div class="form-group">
                        <div class="col-sm-3"></div>
                        <div class="col-sm-2 col-md-offset-3 align-items-center">
                            <button type="button" class="btn btn-sm btn-primary" onclick="btnReplyClick()">
                                <span class="glyphicon glyphicon-ok"></span>&nbsp;修改回复
                            </button>
                        </div>
                    </div>
                </div>
            </div>
            <!--     右       -->
            <div class="col-sm-4 entering-page">
                <div class="col-sm-12">
                    <!--   工单基本信息     -->
                    <div class="col-sm-12 tltieBoder">
                        <div class="blueBorder"></div>
                        <h4 style="margin:0 0 0 10px">审查结论</h4>
                    </div>
                    <div class="col-sm-12" >
                        <div class="form-group">
                            <label class="col-sm-3 control-label entering-pd">审查意见：</label>
                            <div class="col-sm-8">
                                <input type="text" id="opinion" name="opinion" class="form-control" >
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-12" >
                        <div class="form-group">
                            <label class="col-sm-3 control-label entering-pd" style="color: red">不通过理由：</label>
                            <div class="col-sm-8">
                                <input type="text" id="txtReason" name="txtReason" class="form-control">
                            </div>
                        </div>
                    </div>
                    <!--按钮-->
                    <div class="col-sm-12" style="display: flex;justify-content: space-around;">
                        <div class="form-group">
                            <div class="col-sm-12" style="margin:100px 0px 0px 0px">
                                <button type="button" class="btn btn-sm btn-success" onclick="passOrNot(1)">通过</button>&nbsp;&nbsp;&nbsp;&nbsp;
                                <button type="button" class="btn btn-sm btn-success" onclick="passOrNot(-1)">不通过</button>&nbsp;&nbsp;&nbsp;&nbsp;
                                <button type="button" class="btn btn-sm btn-light" onclick="parent.closeItem()">关闭</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>

<th:block th:include="include :: footer"/>
<script th:src="@{/js/extension.js}"></script>
<script>
    var prefix = ctx + "gaoxin/system/mTelWF";

    $("#showWorkForm").on("load",function(){//iframe加载完后 高度自适应。
        var showWorkForm = document.getElementById("showWorkForm").contentDocument || document.getElementById("showWorkForm").contentWindow.document,
            frame_height = showWorkForm.documentElement.scrollHeight;
        $("#showWorkForm").height(frame_height);
    });

    function passOrNot(flag){
        var act = parseInt(flag);
        if(act<1){
            if($("#txtReason").val().length<1){
                $.modal.alertWarning("请输入不通过理由");
                return false;
            }
            $("#opinion").val("不同意");
        }
        else{
            if($("#opinion").val().length<1)
                $("#opinion").val("同意");
        }
        //根据当前登录用户的角色决定由哪个部门审查
        var crtPro = $("#setProId").val();
        var sortCode = $('#sortCode').val();
        var crtRole = $("#crtRole").val();
        var stepRoles = "210,240,260,290,310,340";
        if(stepRoles.indexOf(crtRole) > -1){//市级
            if ("11" != sortCode) {
                if (act < 1)
                    $('#backState').val(12);
                else
                    $('#backState').val(11);
            }else{
                //主办
                if("11" != crtPro.toString()){
                    if(act<1){
                        $('#backState').val(12);
                        $("#crtStepId").val("801");
                        $("#crtStepName").val("市级不通过");
                    }
                    else{
                        $('#backState').val(11);
                        $("#crtStepId").val("810");
                        $("#crtStepName").val("待效能办审查");
                    }
                }
                else{//11 普通工单
                    if(act<1){
                        $('#backState').val(12);
                        $("#crtStepId").val("801");
                        $("#crtStepName").val("市级不通过");
                    }
                    else{
                        $('#backState').val(11);
                        $("#crtStepId").val("810");
                        $("#crtStepName").val("待审定结果");
                    }
                }
            }
        }
        else{
            if(act<1){
                $("#backState").val(12);
            }
            else{
                $("#backState").val(11);
            }
        }
        if ($.validate.form()) {
            let url = prefix + "/cmnFile/dlChkReply";
            let data = $('#form-user-add').serializeArray();
            let areaNo = $("#areaNo").val();
            if(areaNo === '510109'){
                $.ajax({
                    url: url,
                    type: "POST",
                    dataType: 'json',
                    data: data,
                    success: function(result) {
                        $.modal.alertSuccess(result.msg);
                        muReplyRefresh();
                    },
                    error: function (){
                        $.modal.alertError("操作失败！");
                    }
                })
            }else{
                parent.$.operate.saveTab(url,data);
            }
        }
    }

    //刷新审核本级回复列表
    function muReplyRefresh() {
        var topWindow = $(window.top.document);
        var currentId = $('.page-tabs-content', topWindow).find('.active').attr('data-panel');
        var navFrame = $('.NAP_iframe[data-id="' + currentId + '"]', topWindow).contents().find('#navFrame')[0];
        navFrame.contentWindow.$.table.refresh();
    }

    //修改回复
    function btnReplyClick(){
        var backDesc = "reply"+$("#backDesc").val();
        $("#backDesc").val(backDesc);
        var data = $('#form-user-add').serializeArray();
        $.ajax({
            url: "/gaoxin/system/mTelWF/btnReplyClick",
            type: "POST",
            dataType: 'json',
            data: data,
            success: function(result) {
                $.modal.alertSuccess("修改成功！");
                history.go(0);
            },
            error: function (){
                $.modal.alertSuccess("修改失败！");
            }
        })
    }

</script>
</body>
</html>

